import store from "../store";

export function getHabit() {
  let obj = {
    styles: 1,
    checkedField: [
      {
        sort: 1,
        title: "主诉",
        name: "medical_describe",
        value: "",
      },
      {
        sort: 2,
        title: "既往史",
        name: "past_history",
        value: "",
      },
      {
        sort: 3,
        title: "个人史",
        name: "personal_history",
        value: "",
      },
      {
        sort: 4,
        title: "过敏史",
        name: "allergy_history",
        value: "",
      },
      {
        sort: 5,
        title: "体格检查",
        name: "tigejiancha",
        value: {
          temperature: "",
          weight: "",
          heart_rate: "",
          blood_pressure_1: "",
          blood_pressure_2: "",
          medical_others: ""
        }
      },
      {
        sort: 10,
        title: "诊断",
        name: "result",
        value: "",
      }
    ],
    checkTypeList: ["成药处方", "饮片处方", "注射液", "常用处方"],
  }
  if(JSON.parse(localStorage.getItem('habit' + store.getters.userInfo.id))){
    return JSON.parse(localStorage.getItem('habit' + store.getters.userInfo.id))
  }else{
    localStorage.setItem('habit' + store.getters.userInfo.id,JSON.stringify(obj))
    return obj
  }
}

export function setHabit(habit) {
  localStorage.setItem('habit' + store.getters.userInfo.id,JSON.stringify(habit))
}

export function getSystemSetting() {
  return JSON.parse(localStorage.getItem('systemSetting')) || {}
}

export function setSystemSetting(data) {
  localStorage.setItem('systemSetting',JSON.stringify(data))
}

export function getPrintSetting() {
  return JSON.parse(localStorage.getItem('printSetting')) || {}
}

export function setPrintSetting(data) {
  localStorage.setItem('printSetting',JSON.stringify(data))
}

export function getUser() {
  return JSON.parse(localStorage.getItem('userData')) || {}
}

export function setUser(data) {
  localStorage.setItem('userData',JSON.stringify(data))
}

export function setCheckTreatment(data) {
  localStorage.setItem('checkTreatment',JSON.stringify(data))
}

export function getCheckTreatment() {
  return JSON.parse(localStorage.getItem('checkTreatment')) || []
}

export function setOtherTreatment(data) {
  localStorage.setItem('otherTreatment',JSON.stringify(data))
}

export function getOtherTreatment() {
  return JSON.parse(localStorage.getItem('otherTreatment')) || []
}

export function setAutomatic(automatic) {
  localStorage.setItem('hisAutomatic',JSON.stringify(automatic))
}

export function getAutomatic() {
  return JSON.parse(localStorage.getItem('hisAutomatic')) || false
}

export function setMessage(data){
  localStorage.setItem('messageList',JSON.stringify(data))
}

export function getMessage(){
  return JSON.parse(localStorage.getItem('messageList')) || {list:[]}
}

export function setBillCheck(data){
  localStorage.setItem('billCheck',JSON.stringify(data))
}

export function getBillCheck(){
  return JSON.parse(localStorage.getItem('billCheck')) || false
}


